package threadPractise;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo implements Runnable {
    @Override
    public void run() {
        System.out.println(System.currentTimeMillis() + ":Thread ID:" + Thread.currentThread().getId());
        try {

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        List<Integer> a = new ArrayList<>();

        ThreadPoolDemo threadPoolDemo = new ThreadPoolDemo();
        Thread thread = new Thread(threadPoolDemo);
        ExecutorService es = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 10; i++) {
//            es.submit(thread);
            es.execute(thread);
        }
        es.shutdown();
    }

}
